package edu.towson.cosc603.coffeemaker;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class InventoryTest {
	Inventory inventory;
	
	@Before
	public void setUp() throws Exception {
		inventory = new Inventory();
	}

	@After
	public void tearDown() throws Exception {
		inventory = null;
	}

	@Test
	public void testGetChocolate() {
		assertEquals(15, inventory.getChocolate());
	}

	@Test
	public void testSetChocolate() {
		inventory.setChocolate(2);
		assertEquals(2, inventory.getChocolate());

		inventory.setChocolate(-1);
		assertEquals(0, inventory.getChocolate());
	}

	@Test
	public void testGetCoffee() {
		assertEquals(15, inventory.getCoffee());
	}

	@Test
	public void testSetCoffee() {
		inventory.setCoffee(2);
		assertEquals(2, inventory.getCoffee());

		inventory.setCoffee(-1);
		assertEquals(0, inventory.getCoffee());
	}

	@Test
	public void testGetMilk() {
		assertEquals(15, inventory.getMilk());
	}

	@Test
	public void testSetMilk() {
		inventory.setMilk(2);
		assertEquals(2, inventory.getMilk());

		inventory.setMilk(-1);
		assertEquals(0, inventory.getMilk());
	}

	@Test
	public void testGetSugar() {
		assertEquals(15, inventory.getSugar());
	}

	@Test
	public void testSetSugar() {
		inventory.setSugar(2);
		assertEquals(2, inventory.getSugar());

		inventory.setSugar(-1);
		assertEquals(0, inventory.getSugar());
	}

	@Test
	public void testEnoughIngredientsTrue() {
		Recipe mocha = new Recipe();
		mocha.setAmtChocolate(10);
		mocha.setAmtCoffee(5);
		mocha.setAmtMilk(3);
		mocha.setAmtSugar(5);
		assertTrue(inventory.enoughIngredients(mocha));
	}

	@Test
	public void testEnoughIngredientsFalse() {
		Recipe mocha = new Recipe();
		mocha.setAmtChocolate(20);
		assertFalse(inventory.enoughIngredients(mocha));

		mocha = new Recipe();
		mocha.setAmtCoffee(50);
		assertFalse(inventory.enoughIngredients(mocha));

		mocha = new Recipe();
		mocha.setAmtMilk(16);
		assertFalse(inventory.enoughIngredients(mocha));

		mocha = new Recipe();
		assertTrue(inventory.enoughIngredients(mocha));
		mocha.setAmtSugar(25);
		assertFalse(inventory.enoughIngredients(mocha));
	}

	@Test
	public void testToStringFalse() {
		String toString = "Coffee: 15\n" +
				"Milk: 15\n" +
				"Sugar: 15\n" +
				"Chocolate: 15\n";
		assertEquals(toString, inventory.toString());
	}

}
